﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Flame.Dlr
{
    public class StreamOutput : MemoryStream
    {
        public class StreamOutputEventArg : EventArgs
        {
            public string Output { get; set; }
        }

        public event EventHandler<StreamOutputEventArg> OnOutput;

        public override void Write(byte[] buffer, int offset, int count)
        {
            if (OnOutput != null)
            {
                OnOutput(this, new StreamOutputEventArg() { Output = Encoding.UTF8.GetString(buffer, offset, count) });
            }
        }
    }
}
